module Main
	where

import Data.List
import Control.Applicative
import System

cyclicPerms :: [a] -> [[a]]
cyclicPerms l = zipWith (++) (tails l) (inits l)

areCyclicPerm :: (Eq a) => [a] -> [a] -> Bool
areCyclicPerm l = any (== l) . cyclicPerms

processFile :: String -> [[(Double, Double)]]
processFile = pf . filter (not . null) . lines
	where
		pf (x:xs) = let (ls, rs) = splitAt (read x) xs
		            in  fmap ((\(x:y:_) -> (x,y)) . map read . words) ls : pf rs
		pf []     = []

main = do
	(f1:f2:_) <- (fmap.fmap) processFile (getArgs >>= mapM readFile)
	mapM_ print $ zipWith areCyclicPerm f1 f2
